<?php
/*******************************************************************************

    FinalsClub.org is a platform for students and faculty to collaborate
    and share their knowledge with the world.

    Copyright (C) 2009  Andrew Magliozzi

    This file is a part of FinalsClub.org.

    FinalsClub.org is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    To contact FinalsClub.org, send an email to info@finalsclub.org, or
    send mail to Finals Club, c/o Veritas Tutors, 1132 Massachusetts Avenue,
    Cambridge, MA 02138.

*******************************************************************************/

class tasksComponents extends sfComponents {

	public function executeRecentcomptasks() {
	
		//only show first 10 completed tasks
		$completed_tasks_array = TaskPeer::retrieveCompletedTasksByGroupId($this->group_id);
		$this->number_completed = sizeof($completed_tasks_array);
		
		if($this->limit)
		{
			$this->completed_tasks = array_slice($completed_tasks_array, 0 , $this->limit);
		}
		else
		{
			$this->completed_tasks = $completed_tasks_array;
		}
		
	}
	
	public function executeLatetasks() {
	
		$date = date("Y-m-d H:i:s", time());
	
		$this->late_tasks = TaskPeer::retrieveLateTasksByGroupIdAndUserId($this->group_id,$this->getUser()->getId(),$date);
	
	}
	
	public function executeUsertasks() {
		
		//subtract a day so that tasks that are due today are shown
		$date = date("Y-m-d H:i:s", time());
		
		$this->user_tasks = TaskPeer::retrieveOpenTasksByUserIdAndGroupId($this->group_id,$this->getUser()->getId(),$date);
	
	}
	
}
